added more tests and implementation