created repeat checking and added prevention of saving if there are errors