fixed bugs so integrate function actually does what it's supposed to now