added js snippet. wait for condition