added button state code