Updated Error handeling