saving almost works, just needs to be optimized