Better js logic and ready function refactor.