replaced dispatch by Hahns
clean up code