split into several files and renamed some functions
added utility function with tests + some documentation