Implemented sub-query validation