make more idiomatic js