Refactor the code and remove unnecessary logs