Implemented deleting and error handling