refactored to consolidate code
added screenshot