replaced generic code with native code