bug fix by Jacob