adjusted constants and added getLength functions