add some comments. move helper code to Utils module