Refactoring script_bd2.php