Added input validation. Now the user can only enter 'a', 'b', 'c', or 'd'.