refactor, cleanup & input options checking