see if you can make this so it can be called as a function, then you don't have to do the weird subprocess calling nonsense.