Adding scale autodetection logic