delete function works a little buggy