wait for button code improvied