fix js bug that was printing duplicates