autodetection reworked