added button toggling logic