modifed to fix the linking problem across different systems