changed a lot in js logic with models