added checkout method and finish method, fixed some code for simplicity