Fixing imag function