Make code more idiomatic (and a bit faster)