Added extra preconditions and more comments