code updated for scripts