slight performance

Improvements in the code to slight performance