delete function almost functional
fixed merge conflicts