included changes to accept -i flag