updated code to work on MAC -abhi