solving problem 12
refactoring: moving useful helper methods to LongUtils