started rewrite of functionality