perodic save-- fixed logic error