js logic currently broken