wrote some tests and the function