improve and update autozoom code