added am class to do the query dirty works