Making code more genertic