Rewrote script structure again, things seem to working better now