refactor mysql queries to use promises