There is an error somewhere in here.. added some debugging