old code refactored to angular mvc