make line more smooth, refactor code