added error check to autocrop