Refactor, update for mysql