fix the off by one issues

Resolves #5