small tweaks to problem2 and refactored version for testing, add benchmarking