added once and improve some performance

I thought it would be a good idea for sharing my code and changes. I have added once and improved some performance.
Thanks