defining functions to handle continuations