handles cases when b occurs before a