code cleanup, more helpful error text