improved mysql interaction