update mapping, unit test and improve code