Add error message and fix bug for value retrieval