Added -R and perror statements