added realtime saving and fixed a bug
fixed a bug