better javascript handling