Small fixes after previous changes
used existing API to reduce code complexity