BuggFix + code refactoring