implemented error logging