js logic unfinished