cleaned up select.cpp and rest of code