Fixed CPU intensive bug