refactor code of calculator and parser