A cleaner trace function