minor js code re-org