Minor bug fix in script