I have no idea if cute is good or bad but I stole this pattern from the node codebase (a good read anytime) see repl