Using dosefunction... copied for use in LP (no need of time)