replace explicit casts with functions