First version (logic only)