added credit and links to some of the code I found on forums that helped