minor refactor and small fix