Refactor: inlined the code to a method that return a
Resultset in order to simplify closing of connections