bug fix for undefined object error