adding some framework before copying over extra logic from the first version