do some code re-factor and update example application.