fix bug with order of declarations