change tables and fix bug