refactoring iterator making it more efficient
refactoring: removing range(len())
Updated api to return {} if query fails
Updating tests for empty dict
refactoring return for querying the database