changed length and width to global vars