full refactor. see samples...