added saving functionality