updated specs and improved code