some general functions and patterns that can be useful