Holy shit. This actually works. except random runtime exception which doesn't affect the performance.