fixed it. Works fine. needs to be refactored.