add PrepareData() + divided functions, refactoring