Updated with Snapchat code style and an optional callback interface.