reduce redundant calculation