resize algorithm

wtf rocky