fixed issues with error logging