Simplify JavaScript