Doesn't indexOf() = 0 means first position? This check should fail any time "-re" is not the first parameter, thus checking for "-i" looks unnecessary to me.