updated to fix bugs