huge change in function organisation for the sake of reusability