improve code & add specs