debugged except for random and delete