better error handeling and whatnot