added changes according to comments from rxin