added more flexibility to code