Fixed a potential bug source
Cleaner implementation