optimizing some js