script fixed to support ajax update