Fixed typo in functions causing 500 error