added update query and refactored all qeuries