debugged code for mac 64 and linux 32