Working except for off by 1 error
Fixed merge conflicts