Fixed bug.
Refactoring