small changes to handle more cases