Refactory of mysql class