added additional check to be sure posts isn't empty