cleaned code along with lagrange interpolation capability