Fixing bugs, add step 3 code