facebook tools (code adapted from a book)