add optimisation to js logic