Removed some unused functions
removed redundant query. reworded another query