removing more duplicated code