Fixed error logging bug