Added dgonyeo's bug fix