merging with Kristjans code