Removed the useless self_loop check and improved formatting