adding some slight refactoring before giving up for now