Make some code more idiomatic