OOP style
included current value to d
added current rate for scripts
working script