updated with link handling and some error handling
weird