modified symphony method, ID pdf had mistake before. if loop had problem too.