fixing infinite level bug