updated nested sample code to make it more readable