some function reorganizations