big logic and db changes