refactor + minor fix