wrote down js logic for #054 (Close #054)