Updated example code with better code layout