Added error handling (kinda)