Added new function for formatting data