works main function