add checkout algorithm