this functionality is already duplicated in a function