added user query and cleaned up some other stuff