turned test into function