Refactored slightly more