Added some error cheching and made strings constant