fix indentation; enhance error logging