fixed error in code and added a test to see if Y or N is entered