complete some function code