updated script(again), continuing on code overhaul