better handling of commit