Refactor/Bug fix