add some error handling/debugging code to rate