minor changes
added conditional code