remove duplicated code, clean up one comment