functionality logic improved