minor refactor + jsbeautify