fix second pass logic