if type == 0 will cause an error