prettified code and added comments