seperate main function