Added data formatting code