FIX: Overflow caused infinite loop in some cases