Plan js refactor