Added data tranformation into suitable format
Made some refactoring