fix undefined res error