slow version of 2.5b with tests
Optimized version of 2.5b