started adding queries and fixing the code to support queries