cleaned up compare_and_set def
made compare and set a macro