improve limited cast pattern