fixes #20
move common routines to utils module
minor refactor