fixes error scenario and issue #459