fixed error in third pass