finalised decay analysis script