Improve the code with dialyzer