generalization of logic
forgot to add files from last commit