modified js logic