initial working version of auto horizontal adjustment