small changes to remove duplicated and commented code.