removes duplicated code