major work on cleaning the implementation