master - moved logic to proper files