Try and speed up js code