Change branch checking logic

@leoniddinershtein, please, give me an advice where I can place this message?