Made code more explicit and followed style guidelines