new geometric functions and code reorganization