make separate functions for common code
start work on SunOS