query class refactored; order and limit queries added