regex was capturing even the spaces when doing the function match leading to unprecedented errors