Trying to make code more generic and re-useable