Moved selection query to controller