refactor transtion js