trying to simplify and clean up (partly working)