prepare_data function

The role of this function is to prepare data in such a way that is ready to use right away in the other functions.