fix error message, add more commenting