version with include _lut inlcuded and one malloc changed