added pagination and cleans the whole directory