remove undefined behavior