major bug fixing