fixed condition checking in unpacking