fixed error in saving and loading entities from file