refactored with Liam W.