autodetect layout