major bug fixed on routine