Refactored using Array.filter()