changed toggle function, directive and added comments