Added error logging feature