minor refactor and performance improvement