added directory check to delete thingy.

made in the online editor - therefore not tested.