made a lot of changes and it works