Refactored and added specs