Made code more idiomatic