Second try to optimize

second condition happens 67557 times