Adding error checking to ensure character input for function