Silly error from not checking emptiness of arrays
still didn't fix major bug