Replaced printf and checks with assert