Added Error logging