refactor codes for social part