adding sort to edit view and catching nil in edit fields before update