fix bug in order of definitions