add unit and clean code