refactor function.php