refactored fb-like code