fixed bugs - now works with old Ryan code