refactored same behavior using view controller object