Applied more optimization : caching named output, reorder check routains in compare func