New wait_for function and a small fix for admin login