multiple levels fix and refactoring

fixed multiple levels bug