Some refactoring for readability and added possibility to provide required message