Method for dual input text or password; Refactoring error code