fixed scope. Refactored.