complete script now working.