Added wait for dom logic