working solution without directives
working example with directive