Added a waiting mechanism so as to ensure the csrf has been added