refactored two methods and made one generic"