formating data & error handling