Alternative solution to fix #345. 

Not necessarily a better solution, but stays consistent with the previous code.