Base js logic