refactored sql queries to separate module