cleaned up post count logic and fixed an off-by-1 bug