Fixed error logging