Finished example and fixed logic bug