implemented solution for the overwriting problem