added comment to clarify this complex script ;)