Updated autofocus feature with js, now working correctly