Actually fixed the function this time