modified main code