took some more code from someone else. lol