adding some helper functions to crunch numbers