Made code more flexible