Updated to clean up queries