fixed more bugs from Jonathan