first implementation of core logic