Error logging fixed