add some logic in waiting and new util function to save user record