optimizing and formating