added Bartschat's code