add refreshing and cancelling
rewrite internal
safer error checking order