Added grant, fixed some errors, updated conditions