Replace a block of stuff that could of just been in a loop
Remove uses of alert, Paving some of the way for a node module