First working version that saves data to function structure.