js serial optimization