refactor: replaced multiple statements with a single call to grepl