refactoring to parameterize facebook code