Fix error in production 'undefined method count for NilClass'