Implemented save function