added save function
added documentation