This will be better as an http interceptor