simplify JS snippet slightly