more changes to js. Haven't done gradient algorithms yet