started rewrite of functionality
started rewrite of functionality