rewrite fetch method for query