added if condition on checkForRepeats