use same method as in c