modifications to fix bugs