removed undef, added a check for a null bin resource