fixed some more logical errors (offset and phi calculation)