Added high-level write_cas method