Simplified logic, did some renaming