now the boundaries takes in account the rotations.But it's buggy