Added Documentation

Added documentation for function to guide
Added inline comments to function