Adapted more from the demo project to get this running