added code to handle subquery

right now, only consider handling one subquery