Optional cast variable when get