refactor codes in facebook api