automatic resizing implemented (small bugs still left)