add specs and fix bugs