Added logic to retrieve data for storing