Fixing some function definitions