rewrote test to make the code simpler