Improve performance by avoiding printf