fix stupid bug, refactor