moved code from local investigate