refactored to use Prime class