added error handling to unpack and fixed hanging promise