cleanup
fix sql bug