Summary: Hiding casting madness and complexity behind a helper function to avoid bugs and improve maintainability. Reviewed By: sammy-SC Differential Revision: D17923549 fbshipit-source-id: 105891d85b0412fa4a17d7ae8a9e156fc1b151fb