Making code more idiomatic