refactored and adding forward references