update with refactored solution