fixing sorting problem
add type cast for functions