refactor demo/main code and improve output of demo