changed camel case to snake case, also changed some error checking