fixed the function, should only work in beginning