fixing minor bugs and adding some lambda expressions to improve performance and decorata code