@polesye Sorry! I did not notice that the 2 if conditions had different blocks of code to execute:

    return $.Deferred().reject().promise();

and

    return $.Deferred().resolve(list).promise();

Please disregard this comment.