better handling of mysql connections