use  instead of setTimeout it worked