add save and some error checking