SPCU: Added final code for accepted answer