fixed issue with save function