trying to avoid too much casts