moved logic out of caller method