refactored casts