first cut a working code