remove undefined behavior

remove undefined behavior, which just worked accidentally.