fix indentation; better error logging