add prototype code from Chong Wang