fixes nullpointer and indexoutofbound in edit