fixing format logic