refactor demo script