corrected error levels, moved close logic to dedicated method