Refactored after review