started moving all logic to javascript