still trying to get all the edge cases
Got it working locally