added more checks for expand()