fixed tables and added index