main function is working now