Fixed array index out of bounds on command handler