remove undefined behaviour