Refactor  specs and implementation