a little bit of error handling, but can't figure out what's up with the last page