replaced slow part with faster & cleaner one