divided program into multiple functions