implemented code for importance sampling