moved save function to own class