Added initial version of optimized solution