split into multiple files, need testing and comments v7