Fix bug when changing width or height