fix function ordering