debugged main script