modified to work on GCC