Some checking to reduce errors not sure if this is a good idea but going to try it out