Change branch checking logic