fix bug on ordering of prototypes expansion