Attempt to improve JS performance