Added error handeling