add tests and adjust the code accordingly