moves js logic to its own file