Fixed an out of range bug
Added formatting