Adding some query logic