check code and change the logic