Code is working... added comments as well.