rewrote test function