refactored a little and added delete functionality