fix overwriting bug