Replaced assert by guard