removed casts where possible