got the math down. just need to make it a function