Added top-level logic