Added more flexibility to code.