rough version of thirdPass, has errors