Refactor: create function displayErrorMessage

display different text message