commented and well aligned code now