abstract some duplicate code because perfectionism

Signed-off-by: Jeremy Massel <jeremy@habithq.ca>
Merge branch 'master' of github.com:habitinc/AllSpark