thorough commenting added