Remove debug printing
Add cast check