Optimize a little JS