cleaning up code
Code is working, but slow