ENH removed helper function, moved all code to the main function. added docstring and bubbling. also makefile