added saving capabilities
fixed bug