Added error handling.
Might need more