Added the code to print in levels