Added some error handling. need more!