bugfixed a few cases that were not handled properly