refactroring core to return value