updated code, need to tidy particle analysis