fixed rules for pagination
fixed bug in template