add tests and throw function