added credits for Jakob; refactored the code a bit