create_ctx() function added