factor out utility functions
code style change