better error handling, especially in mget