updated with changes from comments