Merkel reaches crucial immigration deal