refactored spec code