it now works but needs to be fine tuned