Fixed the error trap