changed some delay to setTimeout