fixed bugs introduced by previous change; everything fully working