Finish the logic of