added save to file functionality