Refactoring Core.php