Remove redundant code and add the necessary