cut duplicated code