updated structure and php code