completely rewrote script