Refactor to make function signitures correct