Bug fix + Refactoring