Changed code & added comments