finished multilevel implementation