Search div and pagination logic issues