Added if statement to stop out of bounds crashes