slightly modified to work with async operation in the callback of parse function.