merged met jorik's code