fixed a bug from wrong function call order