Refactor count to size to make robust and avoid extra sql call