refactored. added spec, attempting to conform to it