Fixed type cast to unsigned which is problmatic