made this line more generic.
made some corrections based on Andrew's comments