facebook graph api code refactored