improved error message
code cleanup