This block appears here and https://github.com/Wikia/app/pull/3800/files#diff-0677cf94deeee06e6ad122d00550f25cR50; can the common logic be refactored into one method?