refactor and prepare sample application