Health package daily step count mismatch on android

I built a step tracker app that updates users’ steps daily. The app works okay while it’s in the foreground, so my main issue lies when the app is in the background. I have added foreground service to help track the steps while the app is in the background but i faced an issue where the value recorded doesn’t tally with values on other apps i have on my device (they all have the same value). This lead me to add health package which supports reading steps from the device hardware based on DateTime passed, this also doesn’t fix the issue because most of the time, the value i get is usually lesser that what’s on other apps. Can anyone that has worked on something similar or shares an opinion on this enlighten me on next steps to follow.