less indentation and better error