Began js logic