Add delay to button state check

Add delay to button state check
Clean up  var declaration