added pagination. fixes #559