Fix bug
remove unused tmp array
clean up code
change method name