quick changes to code

This code needs more work. Could help a bit more if you could provide the schema.