fixed some stuff and added assertions