some modifications, change of variables names