fixed mode hook
used python3
added comments