bug fix + temporary debug code to be removed