Fix for wront error logging