Some code adjustments to make code more idiomatic