working example and basic bug fixes