fix format, eliminate extraneous inner function