Optimiziation

Did some optimizing of the code