fix undefined return value bug