logic moved from bin/