refactor and fixed jumpiness