cleaned up old code
Added dynamic resizing