added option for packet casting