added my refactored version to replace