The logic inside this if was a bit unclear, perhaps some more telling variable names than first and second would help...