refactored for less querying