while merging found a bug, not sure what was rwong with original code, by test.pl demonstrates that it is correct
changed the printing flags, wanting to check if only one function is needed