seperated code into smaller functions