Updated formatting
Fixed off-by-one
Removed unnecessary code