fix errors
exclude some unecessary loops
fix typo apal -> apall