tree functions
cesar improved