code refactor to improve #80