Using cast instead of getting the reference of first element