Refactor demo JS