Another attempt to fix minor bug in code