migrating to external function and testing.