spent 5 minutes on this might as well use it in another thread