Updated code style and added comments