fixed up the snippet such that it now works with the inactive and active states