Fixes a potential out of range error