refactor update and delete methods