Make some code more idiomatic

wow, didn't know this method exists. Thanks!