Error logging added