some codes were improved in rest.php