refactored to replace a few literal checks with REPs