separated main database queries from controller into their own file