refactor demo controller