shaped up code according to style guide. moved all error messages into a dictionary