refactor mysql resource some more