refactoring for rudin and testing