cleaned up the resize code