Refactoring for readability
Updating spec to fix bug