Add a fialure helper class to handle different types of failures, modifiy code to fit the latest db structure