fixed formatting logic