[not-workling] restructuring and refactoring code and ext files