refactored select query to select for a form definition and id tuple