Port sample code to app framework