Added a fix to avoid repeating outputs.