Added database rollback when an error occurs