reusing ridiculously similar code