better working javascript