checking the code in `builtin.cpp`, removed some bugs and redundancy