changed code to C89 standard