working intermintantly still needs logs and some more error control added in