fix potentional bugs
Merge branch 'james'