fixed action bug, started refactoring