renamed a function and fixed a bug