optimize code and fix entry bugs
optimize code and fix entry bugs