Performance improved from 328ms to 316ms, not much improvement :(
Overall algorithm should be refactored.