refactored with .indexOf