added casts to remove xcode complaints