refactor functions.php