some re-ordering of functions