2 << (i - 1) instead of pow(2, i).toInt?