diff --git a/handler/handler.go b/handler/handler.go
index e6e7bea627fce1694e97465f033002ad8206a803..8ca9a05d72229a6ebf7d0b46e96e9ac4f2efa944 100644
--- a/handler/handler.go
+++ b/handler/handler.go
@@ -25,6 +25,7 @@ import (
 
 	"code.vereign.com/code/viam-apis/clientutils"
 
+	"code.vereign.com/code/key-storage-agent/config"
 	keyutils "code.vereign.com/code/key-storage-agent/utils"
 	"code.vereign.com/code/viam-apis/authentication"
 	"code.vereign.com/code/viam-apis/key-storage-agent/api"
@@ -106,7 +107,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
 		getKeyResponse.Key = nil
 		getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList,
 			"500", api.StatusType_ERROR, err.Error())
-		return getKeyResponse, err.Error()
+		return getKeyResponse, err
 	}
 
 	if errorsString != "" {
@@ -121,7 +122,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
 		getKeyResponse.Key = nil
 		getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList,
 			"500", api.StatusType_ERROR, err.Error())
-		return getKeyResponse, err.Error()
+		return getKeyResponse, err
 	}
 
 	getKeyResponse.Key = key
@@ -151,13 +152,13 @@ func (s *KeyStorageServerImpl) SetKey(ctx context.Context, in *api.SetKeyRequest
 
 	key := &api.Key{}
 
-	if ReplaceKey == false {
+	if config.ReplaceKey == false {
 		_, _, err := client.GetData("keys", in.Uuid+"/"+api.KeyType.String(in.KeyType), key)
 		if err != nil {
 			log.Printf("grpc call GetData to DataStorage failed: %s", err)
 			setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList,
 				"500", api.StatusType_ERROR, err.Error())
-			return setKeyResponse, err.Error()
+			return setKeyResponse, err
 		}
 
 		if len(key.Content) > 0 {