Made some code more intuitive and readable