try one of these patterns

source code available on github