simplify and cleanup a bit