added a lot of the code for shrink