fixed up parameter order, added some logging