refactored to reduce redudant tests