final fixed script. yet to design tests