Removed duplicated line
Re-arranged error checking for issue #1319