refactored favorites functionality