clean up code for delete functionality