Added code to fix #1

I believe this change will solve #1.