fix declaration orders and return types