fixing a panic in uint to int conversion