separated into three functions and added if name equals main