Made code more clean and safer.