Using cast that is compatible with OS X as well.