Fix error logging bug